#region Usings
using System;
#endregion

namespace Bk.Import.CashOrganizer
{
    public class CoTransaction : CoInfoBlock
    {
        #region Fields
        private string _account;
        #endregion

        #region C'tors
        public CoTransaction()
        {
        }

        public CoTransaction(CoInfoBlock infoBlock) : base(infoBlock, CoInfoBlockType.TypeBank)
        {
        }
        #endregion

        #region Instance Properties
        public string Account
        {
            get { return _account; }

            set { _account = value; }
        }

        public new string Category
        {
            get
            {
                string[] strings = base.Category.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
                return strings[0];
            }
            set
            {
                string bufferedClass = Class;
                base.Category = Category == Account ? string.Format("[{0}]", Category) : Category;
                base.Category = bufferedClass != null ? string.Format("{0}/{1}", value, bufferedClass) : base.Category;
            }
        }

        public string Class
        {
            get
            {
                string[] strings = base.Category.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
                return strings.Length == 2 ? strings[1] : null;
            }
            set
            {
                base.Category = Category == Account ? string.Format("[{0}]", Category) : Category;
                base.Category = value != null ? string.Format("{0}/{1}", base.Category, value) : base.Category;
            }
        }
        #endregion
    }
}